/*
 * @Description: 
 * @Date: 2025-07-01 10:00:41
 * @LastEditTime: 2025-08-13 15:43:59
 */
import { defineConfig, loadEnv } from "vite";
import vue from "@vitejs/plugin-vue";
import path from "path";
import BASIC_SSL from "@vitejs/plugin-basic-ssl"
export default ({ mode }) => {
  // Load app-level env vars to node-level env vars.
  process.env = {...process.env, ...loadEnv(mode, process.cwd())};

  return defineConfig({
    plugins: [vue()],
    resolve: {
      alias: {
        "@": path.resolve(__dirname, "./src"),
      },
    },
    base: process.env.VITE_APP_BASE_URI,
    server: {
      host: '0.0.0.0',  
      proxy: {
        '/api': {
          target: 'http://192.168.43.158:10008/',   // 后端 API 地址
          changeOrigin: true,                // 改变请求源，避免 CORS 问题
          secure: false,                     // 如果是https接口，需要配置为false
          rewrite: (path) => path.replace(/^\/api/, ''),  // 重写路径，去掉/api前缀
        },
      },
    },
  });
}

